<?php


namespace App\Logic;


class split
{
    public function setTable($table)

    {

        $this->table = $table;



        return $this;

    }

    //分表算法
    public function changeTable($companyId) {
        // 分表算法，根据companyId选择分表，请勿修改算法，以免混淆分表数据
        //取模 10 的余数。如果余数不为零，表名将为 "demo_$posfix"，否则表名为 "demo"
        $posfix = intval($companyId) % 10;
        $tableName = $posfix ? "demo_$posfix" : 'demo';
        return $this->setTable($tableName);
    }

    public function countCompanyData($companyId, $condition) {
        return $this->changeTable($companyId)->multiwhere($condition)->count();
    }
}
